<!--Javascript-->
<script type="text/javascript" src="<?php echo base_url().'assets/js/jquery.min.js';?>"></script>
<script type="text/javascript" src="<?php echo base_url().'assets/js/bootstrap.min.js';?>"></script>
<script type="text/javascript" src="<?php echo base_url().'assets/js/bootstrap-datepicker.js';?>"></script>

<!-- Add mousewheel plugin (this is optional) -->
<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/fancybox/lib/jquery.mousewheel-3.0.6.pack.js"></script>

<!-- Add fancyBox -->
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/lib/fancybox/source/jquery.fancybox.css?v=2.1.4" type="text/css" media="screen" />
<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.4"></script>

<!-- Optionally add helpers - button, thumbnail and/or media -->
<link rel="stylesheet" href="<?php echo base_url(); ?>assets/lib/fancybox/source/helpers/jquery.fancybox-buttons.css?v=1.0.5" type="text/css" media="screen" />
<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/fancybox/source/helpers/jquery.fancybox-buttons.js?v=1.0.5"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/fancybox/source/helpers/jquery.fancybox-media.js?v=1.0.5"></script>

<!-- datatables -->
<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/datatables/js/jquery.dataTables.min.js"></script>

<!-- chosen -->
<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/chosen/chosen.jquery.min.js"></script>

<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/fancybox/source/helpers/jquery.fancybox-thumbs.js?v=1.0.7"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/lib/tinymce/js/tinymce/jquery.tinymce.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/authentication.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/big-modal.js"></script>
<script type="text/javascript">	
	var loader = "<img src='<?php echo base_url() ?>assets/img/ajax-loader.gif' >";
	var base_url = "<?php echo base_url() ?>";
	
	$(document).ready(function(){
			$("#signin").click(function(e){
				$("#login-form").validate();
				e.preventDefault;
				if($("#login-form").valid())
					login($("#strEmail").val(), $("#strPass").val()); 
			});
			$(".textinput").keydown(function(e)
			{
				if(e.keyCode=="13")
				{
					if($("#login-form").valid())
					login($("#strEmail").val(), $("#strPass").val()); 
				}
			});
			$("#forgot-btn").click(function(){
				$("#login-modal").fadeOut("fast");
			});
		
			$("#forgot-password").click(function(){
				$("#forgot-password-form").validate();
					if($("#forgot-password-form").valid()){
						$("#forgot-password").hide();
						show_loading_gif("#forgot-password-form .button-set");
						forgot_password($("#email-forgot-address").val());
					}else{
						$("#email-forgot-address").val('');
					}
			});
		});
		
		
		
		function forgot_password(_email)
		{
			$.post(base_url + "account/forgot/", {
				email: _email
			}, function(response){
				if(response){
					modal_message("An email with the reset link has been sent to your email address.");					
					 $("#forgot-password").show();
                    hide_loading_gif();
				}else{
					modal_message("That email address does not exist on our databases");
                    $("#forgot-password").show();
                    hide_loading_gif();
				}				
			});
		}
		
		function login(_email, _password)
		{
			$.post("<?php echo base_url(); ?>users/auth/", {
				strEmail: _email,
				strPass: _password
			}, function(response){
				loginUser(response);
			});
			
			return false;
		}
	
</script>

		
	
	